package com.bwie.controller;

import com.bwie.pojo.THb;
import com.bwie.pojo.THy;
import com.bwie.pojo.TUser;
import com.bwie.service.THbService;
import com.bwie.service.THyService;
import com.bwie.service.TUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginInfoVo;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sun.security.krb5.internal.PAData;

@RequestMapping("/user/index")
@RestController
public class UserControlelr {

    @Autowired
    TUserService tUserService;

    @Autowired
    THyService tHyService;

    @Autowired
    THbService tHbService;

    //用户登录
    @PostMapping("/login")
    public R login(@RequestBody LoginInfoVo loginInfoVo){
        return tUserService.login(loginInfoVo);
    }

    //注册用户
    @PostMapping("/addUser")
    public R addUser(@RequestBody TUser tUser){
        return tUserService.addUser(tUser);
    }
    //发送验证码
    @PostMapping("/sendCode/{mobile}")
    public R sendCode(@PathVariable("mobile")String mobile){
        return tUserService.sendCode(mobile);
    }


     //好友列表
    @PostMapping("/listHY")
    public R listHY(@RequestBody PageInfoVo pageInfoVo){
        return tHyService.listHY(pageInfoVo);
    }
    //删除好友
    @PostMapping("/deleteHY/{hyId}")
    public R deleteHY(@PathVariable("hyId")String hyId){
        return tHyService.deleteHY(hyId);
    }

    //添加好友
    @PostMapping("/addHY")
    public R addHY(@RequestBody THy tHy){
        return tHyService.addHY(tHy);
    }

    //红包列表
    @PostMapping("/listHB")
    public R listHB(@RequestBody PageInfoVo pageInfoVo){
        return tHbService.listHB(pageInfoVo);
    }
    //发送红包按钮
    @PostMapping("/addHB")
    public R addHB(@RequestBody THb tHb){
        return tHbService.addHB(tHb);
    }

}
